package com.qijia.common.dao.impl;

import java.util.List;


import com.qijia.common.dao.UsersDao;
import com.qijia.common.domain.Users;
import com.qijia.common.utils.ListUtils;

/**
 * A data access object (DAO) providing persistence and search support for
 * CommonUsers entities. Transaction control of the save(), update() and
 * delete() operations must be handled externally by senders of these methods or
 * must be manually added to each of these methods for data to be persisted to
 * the JPA datastore.
 * 
 * @see com.qijia.common.domain.CommonUsers
 * @author MyEclipse Persistence Tools
 */

public class UsersDaoImpl extends JpaDaoSupportImpl<Users> implements UsersDao {
	// property constants
	public static final String ENABLE = "enable";
	public static final String PASSWORD = "password";
	public static final String USERNAME = "username";

	public List<Users> findByEnable(Object enable, int... rowStartIdxAndCount) {
		return findByProperty(ENABLE, enable, rowStartIdxAndCount);
	}

	public Users findByUsername(String username) {
		List<Users> users = findByProperty(USERNAME, username);

		if (ListUtils.isEmpty(users))
			return null;
		else
			return users.get(0);
	}
}